home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / gnu / a2_0bEmacs_bin.lha / Emacs-19.25 / info / termcap-1 < prev    next >
Text File  |  1992-02-21  |  49KB  |  1,186 lines

  1. Info file ../info/termcap, produced by Makeinfo, -*- Text -*- from
  2. input file termcap.texinfo.
  3.  
  4. This file documents the termcap library of the GNU system.
  5.  
  6. Copyright (C) 1988 Free Software Foundation, Inc.
  7.  
  8. Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12. Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that
  14. the entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.  
  17. Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that this permission notice may be stated in a
  20. translation approved by the Foundation.
  21.  
  22.  
  23. 
  24. File: termcap,  Node: Top,  Next: Introduction,  Prev: (DIR),  Up: (DIR)
  25.  
  26. * Menu:
  27.  
  28. * Introduction::What is termcap?  Why this manual?
  29. * Library::     The termcap library functions.
  30. * Data Base::   What terminal descriptions in `/etc/termcap' look like.
  31. * Capabilities::Definitions of the individual terminal capabilities:
  32.                  how to write them in descriptions, and how to use
  33.                  their values to do display updating.
  34. * Summary::    Brief table of capability names and their meanings.
  35. * Var Index::   Index of C functions and variables.
  36. * Cap Index::   Index of termcap capabilities.
  37. * Index::       Concept index.
  38.  
  39.  
  40. 
  41. File: termcap,  Node: Introduction,  Next: Library,  Prev: Top,  Up: Top
  42.  
  43. Introduction
  44. ************
  45.  
  46. "Termcap" is a library and data base that enables programs to use
  47. display terminals in a terminal-independent manner.  It originated in
  48. Berkeley Unix.
  49.  
  50. The termcap data base describes the capabilities of hundreds of
  51. different display terminals in great detail.  Some examples of the
  52. information recorded for a terminal could include how many columns
  53. wide it is, what string to send to move the cursor to an arbitrary
  54. position (including how to encode the row and column numbers), how to
  55. scroll the screen up one or several lines, and how much padding is
  56. needed for such a scrolling operation.
  57.  
  58. The termcap library is provided for easy access this data base in
  59. programs that want to do terminal-independent character-based display
  60. output.
  61.  
  62. This manual describes the GNU version of the termcap library, which
  63. has some extensions over the Unix version.  All the extensions are
  64. identified as such, so this manual also tells you how to use the Unix
  65. termcap.
  66.  
  67. The GNU version of the termcap library is available free as source
  68. code, for use in free programs, and runs on Unix and VMS systems (at
  69. least).  You can find it in the GNU Emacs distribution in the files
  70. `termcap.c' and `tparam.c'.
  71.  
  72. This manual was written for the GNU project, whose goal is to develop
  73. a complete free operating system upward-compatible with Unix for user
  74. programs.  The project is approximately two thirds complete.  For
  75. more information on the GNU project, including the GNU Emacs editor
  76. and the mostly-portable optimizing C compiler, send one dollar to
  77.  
  78.      Free Software Foundation
  79.      675 Mass Ave
  80.      Cambridge, MA 02139
  81.  
  82.  
  83. 
  84. File: termcap,  Node: Library,  Next: Data Base,  Prev: Introduction,  Up: Top
  85.  
  86. The Termcap Library
  87. *******************
  88.  
  89. The termcap library is the application programmer's interface to the
  90. termcap data base.  It contains functions for the following purposes:
  91.  
  92.    * Finding the description of the user's terminal type (`tgetent').
  93.  
  94.    * Interrogating the description for information on various topics
  95.      (`tgetnum', `tgetflag', `tgetstr').
  96.  
  97.    * Computing and performing padding (`tputs').
  98.  
  99.    * Encoding numeric parameters such as cursor positions into the
  100.      terminal-specific form required for display commands (`tparam',
  101.      `tgoto').
  102.  
  103. * Menu:
  104.  
  105. * Preparation:: Preparing to use the termcap library.
  106. * Find::        Finding the description of the terminal being used.
  107. * Interrogate:: Interrogating the description for particular capabilities.
  108. * Initialize::  Initialization for output using termcap.
  109. * Padding::     Outputting padding.
  110. * Parameters::  Encoding parameters such as cursor positions.
  111.  
  112.  
  113. 
  114. File: termcap,  Node: Preparation,  Next: Find,  Prev: Library,  Up: Library
  115.  
  116. Preparing to Use the Termcap Library
  117. ====================================
  118.  
  119. To use the termcap library in a program, you need two kinds of
  120. preparation:
  121.  
  122.    * The compiler needs declarations of the functions and variables
  123.      in the library.
  124.  
  125.      On GNU systems, it suffices to include the header file
  126.      `termcap.h' in each source file that uses these functions and
  127.      variables.
  128.  
  129.      On Unix systems, there is often no such header file.  Then you
  130.      must explictly declare the variables as external.  You can do
  131.      likewise for the functions, or let them be implicitly declared
  132.      and cast their values from type `int' to the appropriate type.
  133.  
  134.      We illustrate the declarations of the individual termcap library
  135.      functions with ANSI C prototypes because they show how to pass
  136.      the arguments.  If you are not using the GNU C compiler, you
  137.      probably cannot use function prototypes, so omit the argument
  138.      types and names from your declarations.
  139.  
  140.    * The linker needs to search the library.  Usually either
  141.      `-ltermcap' or `-ltermlib' as an argument when linking will do
  142.      this.
  143.  
  144.  
  145. 
  146. File: termcap,  Node: Find,  Next: Interrogate,  Prev: Preparation,  Up: Library
  147.  
  148. Finding a Terminal Description: `tgetent'
  149. =========================================
  150.  
  151. An application program that is going to use termcap must first look
  152. up the description of the terminal type in use.  This is done by
  153. calling `tgetent', whose declaration in ANSI Standard C looks like:
  154.  
  155.      int tgetent (char *BUFFER, char *TERMTYPE);
  156.  
  157. This function finds the description and remembers it internally so
  158. that you can interrogate it about specific terminal capabilities
  159. (*note Interrogate::.).
  160.  
  161. The argument TERMTYPE is a string which is the name for the type of
  162. terminal to look up.  Usually you would obtain this from the
  163. environment variable `TERM' using `getenv ("TERM")'.
  164.  
  165. If you are using the GNU version of termcap, you can alternatively
  166. ask `tgetent' to allocate enough space.  Pass a null pointer for
  167. BUFFER, and `tgetent' itself allocates the storage using `malloc'. 
  168. In this case the returned value on success is the address of the
  169. storage, cast to `int'.  But normally there is no need for you to
  170. look at the address.  Do not free the storage yourself.
  171.  
  172. With the Unix version of termcap, you must allocate space for the
  173. description yourself and pass the address of the space as the
  174. argument BUFFER.  There is no way you can tell how much space is
  175. needed, so the convention is to allocate a buffer 2048 characters
  176. long and assume that is enough.  (Formerly the convention was to
  177. allocate 1024 characters and assume that was enough.  But one day,
  178. for one kind of terminal, that was not enough.)
  179.  
  180. No matter how the space to store the description has been obtained,
  181. termcap records its address internally for use when you later
  182. interrogate the description with `tgetnum', `tgetstr' or `tgetflag'. 
  183. If the buffer was allocated by termcap, it will be freed by termcap
  184. too if you call `tgetent' again.  If the buffer was provided by you,
  185. you must make sure that its contents remain unchanged for as long as
  186. you still plan to interrogate the description.
  187.  
  188. The return value of `tgetent' is -1 if there is some difficulty
  189. accessing the data base of terminal types, 0 if the data base is
  190. accessible but the specified type is not defined in it, and some
  191. other value otherwise.
  192.  
  193. Here is how you might use the function `tgetent':
  194.  
  195.      #ifdef unix
  196.      static char term_buffer[2048];
  197.      #else
  198.      #define term_buffer 0
  199.      #endif
  200.      
  201.      init_terminal_data ()
  202.      {
  203.        char *termtype = getenv ("TERM");
  204.        int success;
  205.      
  206.        if (termtype == 0)
  207.          fatal ("Specify a terminal type with `setenv TERM <yourtype>'.\n");
  208.      
  209.        success = tgetent (term_buffer, termtype);
  210.        if (success < 0)
  211.          fatal ("Could not access the termcap data base.\n");
  212.        if (success == 0)
  213.          fatal ("Terminal type `%s' is not defined.\n", termtype);
  214.      }
  215.  
  216. Here we assume the function `fatal' prints an error message and exits.
  217.  
  218. If the environment variable `TERMCAP' is defined, its value is used
  219. to override the terminal type data base.  The function `tgetent'
  220. checks the value of `TERMCAP' automatically.  If the value starts
  221. with `/' then it is taken as a file name to use as the data base
  222. file, instead of `/etc/termcap' which is the standard data base.  If
  223. the value does not start with `/' then it is itself used as the
  224. terminal description, provided that the terminal type TERMTYPE is
  225. among the types it claims to apply to.  *Note Data Base::, for
  226. information on the format of a terminal description.
  227.  
  228.  
  229. 
  230. File: termcap,  Node: Interrogate,  Next: Initialize,  Prev: Find,  Up: Library
  231.  
  232. Interrogating the Terminal Description
  233. ======================================
  234.  
  235. Each piece of information recorded in a terminal description is
  236. called a "capability".  Each defined terminal capability has a
  237. two-letter code name and a specific meaning.  For example, the number
  238. of columns is named `co'.  *Note Capabilities::, for definitions of
  239. all the standard capability names.
  240.  
  241. Once you have found the proper terminal description with `tgetent'
  242. (*note Find::.), your application program must "interrogate" it for
  243. various terminal capabilities.  You must specify the two-letter code
  244. of the capability whose value you seek.
  245.  
  246. Capability values can be numeric, boolean (capability is either
  247. present or absent) or strings.  Any particular capability always has
  248. the same value type; for example, `co' always has a numeric value,
  249. while `am' (automatic wrap at margin) is always a flag, and `cm'
  250. (cursor motion command) always has a string value.  The documentation
  251. of each capability says which type of value it has.
  252.  
  253. There are three functions to use to get the value of a capability,
  254. depending on the type of value the capability has.  Here are their
  255. declarations in ANSI C:
  256.  
  257.      int tgetnum (char *NAME);
  258.      int tgetflag (char *NAME);
  259.      char *tgetstr (char *NAME, char **AREA);
  260.  
  261. `tgetnum'
  262.      Use `tgetnum' to get a capability value that is numeric.  The
  263.      argument NAME is the two-letter code name of the capability.  If
  264.      the capability is present, `tgetnum' returns the numeric value
  265.      (which is nonnegative).  If the capability is not mentioned in
  266.      the terminal description, `tgetnum' returns -1.
  267.  
  268. `tgetflag'
  269.      Use `tgetflag' to get a boolean value.  If the capability NAME
  270.      is present in the terminal description, `tgetflag' returns 1;
  271.      otherwise, it returns 0.
  272.  
  273. `tgetstr'
  274.      Use `tgetstr' to get a string value.  It returns a pointer to a
  275.      string which is the capability value, or a null pointer if the
  276.      capability is not present in the terminal description.
  277.  
  278.      There are two ways `tgetstr' can find space to store the string
  279.      value:
  280.  
  281.         * You can ask `tgetstr' to allocate the space.  Pass a null
  282.           pointer for the argument AREA, and `tgetstr' will use
  283.           `malloc' to allocate storage big enough for the value. 
  284.           Termcap will never free this storage or refer to it again;
  285.           you should free it when you are finished with it.
  286.  
  287.           This method is more robust, since there is no need to guess
  288.           how much space is needed.  But it is supported only by the
  289.           GNU termcap library.
  290.  
  291.         * You can provide the space.  Provide for the argument AREA
  292.           the address of a pointer variable of type `char *'.  Before
  293.           calling `tgetstr', initialize the variable to point at
  294.           available space.  Then `tgetstr' will store the string
  295.           value in that space and will increment the pointer variable
  296.           to point after the space that has been used.  You can use
  297.           the same pointer variable for many calls to `tgetstr'.
  298.  
  299.           There is no way to determine how much space is needed for a
  300.           single string, and no way for you to prevent or handle
  301.           overflow of the area you have provided.  However, you can
  302.           be sure that the total size of all the string values you
  303.           will obtain from the terminal description is no greater
  304.           than the size of the description (unless you get the same
  305.           capability twice).  You can determine that size with
  306.           `strlen' on the buffer you provided to `tgetent'.  See
  307.           below for an example.
  308.  
  309.           Providing the space yourself is the only method supported
  310.           by the Unix version of termcap.
  311.  
  312. Note that you do not have to specify a terminal type or terminal
  313. description for the interrogation functions.  They automatically use
  314. the description found by the most recent call to `tgetent'.
  315.  
  316. Here is an example of interrogating a terminal description for
  317. various capabilities, with conditionals to select between the Unix
  318. and GNU methods of providing buffer space.
  319.  
  320.      char *tgetstr ();
  321.      
  322.      char *cl_string, *cm_string;
  323.      int height;
  324.      int width;
  325.      int auto_wrap;
  326.      
  327.      char PC;   /* For tputs.  */
  328.      char *BC;  /* For tgoto.  */
  329.      char *UP;
  330.      
  331.      interrogate_terminal ()
  332.      {
  333.      #ifdef UNIX
  334.        /* Here we assume that an explicit term_buffer
  335.           was provided to tgetent.  */
  336.        char *buffer
  337.          = (char *) malloc (strlen (term_buffer));
  338.      #define BUFFADDR &buffer
  339.      #else
  340.      #define BUFFADDR 0
  341.      #endif
  342.      
  343.        char *temp;
  344.      
  345.        /* Extract information we will use.  */
  346.        cl_string = tgetstr ("cl", BUFFADDR);
  347.        cm_string = tgetstr ("cm", BUFFADDR);
  348.        auto_wrap = tgetflag ("am");
  349.        height = tgetnum ("li");
  350.        width = tgetnum ("co");
  351.      
  352.        /* Extract information that termcap functions use.  */
  353.        temp = tgetstr ("pc", BUFFADDR);
  354.        PC = temp ? *temp : 0;
  355.        BC = tgetstr ("le", BUFFADDR);
  356.        UP = tgetstr ("up", BUFFADDR);
  357.      }
  358.  
  359. *Note Padding::, for information on the variable `PC'.  *Note Using
  360. Parameters::, for information on `UP' and `BC'.
  361.  
  362.  
  363. 
  364. File: termcap,  Node: Initialize,  Next: Padding,  Prev: Interrogate,  Up: Library
  365.  
  366. Initialization for Use of Termcap
  367. =================================
  368.  
  369. Before starting to output commands to a terminal using termcap, an
  370. application program should do two things:
  371.  
  372.    * Initialize various global variables which termcap library output
  373.      functions refer to.  These include `PC' and `ospeed' for padding
  374.      (*note Output Padding::.) and `UP' and `BC' for cursor motion
  375.      (*note tgoto::.).
  376.  
  377.    * Tell the kernel to turn off alteration and padding of
  378.      horizontal-tab characters sent to the terminal.
  379.  
  380. To turn off output processing in Berkeley Unix you would use `ioctl'
  381. with code `TIOCLSET' to set the bit named `LLITOUT', and clear the
  382. bits `ANYDELAY' using `TIOCSETN'.  In POSIX or System V, you must
  383. clear the bit named `OPOST'.  Refer to the system documentation for
  384. details.
  385.  
  386. If you do not set the terminal flags properly, some older terminals
  387. will not work.  This is because their commands may contain the
  388. characters that normally signify newline, carriage return and
  389. horizontal tab--characters which the kernel thinks it ought to modify
  390. before output.
  391.  
  392. When you change the kernel's terminal flags, you must arrange to
  393. restore them to their normal state when your program exits.  This
  394. implies that the program must catch fatal signals such as `SIGQUIT'
  395. and `SIGINT' and restore the old terminal flags before actually
  396. terminating.
  397.  
  398. Modern terminals' commands do not use these special characters, so if
  399. you do not care about problems with old terminals, you can leave the
  400. kernel's terminal flags unaltered.
  401.  
  402.  
  403. 
  404. File: termcap,  Node: Padding,  Next: Parameters,  Prev: Initialize,  Up: Library
  405.  
  406. Padding
  407. =======
  408.  
  409. "Padding" means outputting null characters following a terminal
  410. display command that takes a long time to execute.  The terminal
  411. description says which commands require padding and how much; the
  412. function `tputs', described below, outputs a terminal command while
  413. extracting from it the padding information, and then outputs the
  414. padding that is necessary.
  415.  
  416. * Menu:
  417.  
  418. * Why Pad::          Explanation of padding.
  419. * Describe Padding:: The data base says how much padding a terminal needs.
  420. * Output Padding::   Using `tputs' to output the needed padding.
  421.  
  422.  
  423. 
  424. File: termcap,  Node: Why Pad,  Next: Describe Padding,  Prev: Padding,  Up: Padding
  425.  
  426. Why Pad, and How
  427. ----------------
  428.  
  429. Most types of terminal have commands that take longer to execute than
  430. they do to send over a high-speed line.  For example, clearing the
  431. screen may take 20msec once the entire command is received.  During
  432. that time, on a 9600 bps line, the terminal could receive about 20
  433. additional output characters while still busy clearing the screen. 
  434. Every terminal has a certain amount of buffering capacity to remember
  435. output characters that cannot be processed yet, but too many slow
  436. commands in a row can cause the buffer to fill up.  Then any
  437. additional output that cannot be processed immediately will be lost.
  438.  
  439. To avoid this problem, we normally follow each display command with
  440. enough useless charaters (usually null characters) to fill up the
  441. time that the display command needs to execute.  This does the job if
  442. the terminal throws away null characters without using up space in
  443. the buffer (which most terminals do).  If enough padding is used, no
  444. output can ever be lost.  The right amount of padding avoids loss of
  445. output without slowing down operation, since the time used to
  446. transmit padding is time that nothing else could be done.
  447.  
  448. The number of padding characters needed for an operation depends on
  449. the line speed.  In fact, it is proportional to the line speed.  A
  450. 9600 baud line transmits about one character per msec, so the clear
  451. screen command in the example above would need about 20 characters of
  452. padding.  At 1200 baud, however, only about 3 characters of padding
  453. are needed to fill up 20msec.
  454.  
  455.  
  456. 
  457. File: termcap,  Node: Describe Padding,  Next: Output Padding,  Prev: Why Pad,  Up: Padding
  458.  
  459. Specifying Padding in a Terminal Description
  460. --------------------------------------------
  461.  
  462. In the terminal description, the amount of padding required by each
  463. display command is recorded as a sequence of digits at the front of
  464. the command.  These digits specify the padding time in msec.  They
  465. can be followed optionally by a decimal point and one more digit,
  466. which is a number of tenths of msec.
  467.  
  468. Sometimes the padding needed by a command depends on the cursor
  469. position.  For example, the time taken by an "insert line" command is
  470. usually proportional to the number of lines that need to be moved
  471. down or cleared.  An asterisk (`*') following the padding time says
  472. that the time should be multiplied by the number of screen lines
  473. affected by the command.
  474.  
  475.      :al=1.3*\E[L:
  476.  
  477. is used to describe the "insert line" command for a certain terminal.
  478. The padding required is 1.3 msec per line affected.  The command
  479. itself is `ESC [ L'.
  480.  
  481. The padding time specified in this way tells `tputs' how many pad
  482. characters to output.  *Note Output Padding::.
  483.  
  484. Two special capability values affect padding for all commands.  These
  485. are the `pc' and `pb'.  The variable `pc' specifies the character to
  486. pad with, and `pb' the speed below which no padding is needed.  The
  487. defaults for these variables, a null character and 0, are correct for
  488. most terminals.  *Note Pad Specs::.
  489.  
  490.  
  491. 
  492. File: termcap,  Node: Output Padding,  Prev: Describe Padding,  Up: Padding
  493.  
  494. Performing Padding with `tputs'
  495. -------------------------------
  496.  
  497. Use the termcap function `tputs' to output a string containing an
  498. optional padding spec of the form described above (*note Describe
  499. Padding::.).  The function `tputs' strips off and decodes the padding
  500. spec, outputs the rest of the string, and then outputs the
  501. appropriate padding.  Here is its declaration in ANSI C:
  502.  
  503.      char PC;
  504.      short ospeed;
  505.      
  506.      int tputs (char *STRING, int NLINES, int (*OUTFUN) ());
  507.  
  508. Here STRING is the string (including padding spec) to be output;
  509. NLINES is the number of lines affected by the operation, which is
  510. used to multiply the amount of padding if the padding spec ends with
  511. a `*'.  Finally, OUTFUN is a function (such as `fputchar') that is
  512. called to output each character.  When actually called, OUTFUN should
  513. expect one argument, a character.
  514.  
  515. The operation of `tputs' is controlled by two global variables,
  516. `ospeed' and `PC'.  The value of `ospeed' is supposed to be the
  517. terminal output speed, encoded as in the `ioctl' system call which
  518. gets the speed information.  This is needed to compute the number of
  519. padding characters.  The value of `PC' is the character used for
  520. padding.
  521.  
  522. You are responsible for storing suitable values into these variables
  523. before using `tputs'.  The value stored into the `PC' variable should
  524. be taken from the `pc' capability in the terminal description (*note
  525. Pad Specs::.).  Store zero in `PC' if there is no `pc' capability.
  526.  
  527. The argument NLINES requires some thought.  Normally, it should be
  528. the number of lines whose contents will be cleared or moved by the
  529. command.  For cursor motion commands, or commands that do editing
  530. within one line, use the value 1.  For most commands that affect
  531. multiple lines, such as `al' (insert a line) and `cd' (clear from the
  532. cursor to the end of the screen), NLINES should be the screen height
  533. minus the current vertical position (origin 0).  For multiple insert
  534. and scroll commands such as `AL' (insert multiple lines), that same
  535. value for NLINES is correct; the number of lines being inserted is
  536. not correct.
  537.  
  538. If a "scroll window" feature is used to reduce the number of lines
  539. affected by a command, the value of NLINES should take this into
  540. account.  This is because the delay time required depends on how much
  541. work the terminal has to do, and the scroll window feature reduces
  542. the work.  *Note Scrolling::.
  543.  
  544. Commands such as `ic' and `dc' (insert or delete characters) are
  545. problematical because the padding needed by these commands is
  546. proportional to the number of characters affected, which is the
  547. number of columns from the cursor to the end of the line.  It would
  548. be nice to have a way to specify such a dependence, and there is no
  549. need for dependence on vertical position in these commands, so it is
  550. an obvious idea to say that for these commands NLINES should really
  551. be the number of columns affected.  However, the definition of
  552. termcap clearly says that NLINES is always the number of lines
  553. affected, even in this case, where it is always 1.  It is not easy to
  554. change this rule now, because too many programs and terminal
  555. descriptions have been written to follow it.
  556.  
  557. Because NLINES is always 1 for the `ic' and `dc' strings, there is no
  558. reason for them to use `*', but some of them do.  These should be
  559. corrected by deleting the `*'.  If, some day, such entries have
  560. disappeared, it may be possible to change to a more useful convention
  561. for the NLINES argument for these operations without breaking any
  562. programs.
  563.  
  564.  
  565. 
  566. File: termcap,  Node: Parameters,  Prev: Padding,  Up: Library
  567.  
  568. Filling In Parameters
  569. =====================
  570.  
  571. Some terminal control strings require numeric "parameters".  For
  572. example, when you move the cursor, you need to say what horizontal
  573. and vertical positions to move it to.  The value of the terminal's
  574. `cm' capability, which says how to move the cursor, cannot simply be
  575. a string of characters; it must say how to express the cursor
  576. position numbers and where to put them within the command.
  577.  
  578. The specifications of termcap include conventions as to which
  579. string-valued capabilities require parameters, how many parameters,
  580. and what the parameters mean; for example, it defines the `cm' string
  581. to take two parameters, the vertical and horizontal positions, with
  582. 0,0 being the upper left corner.  These conventions are described
  583. where the individual commands are documented.
  584.  
  585. Termcap also defines a language used within the capability definition
  586. for specifying how and where to encode the parameters for output. 
  587. This language uses character sequences starting with `%'.  (This is
  588. the same idea as `printf', but the details are different.)  The
  589. language for parameter encoding is described in this section.
  590.  
  591. A program that is doing display output calls the functions `tparam'
  592. or `tgoto' to encode parameters according to the specifications. 
  593. These functions produce a string containing the actual commands to be
  594. output (as well a padding spec which must be processed with `tputs';
  595. *note Padding::.).
  596.  
  597. * Menu:
  598.  
  599. * Encode Parameters:: The language for encoding parameters.
  600. * Using Parameters::  Outputting a string command with parameters.
  601.  
  602.  
  603. 
  604. File: termcap,  Node: Encode Parameters,  Next: Using Parameters,  Prev: Parameters,  Up: Parameters
  605.  
  606. Describing the Encoding
  607. -----------------------
  608.  
  609. A terminal command string that requires parameters contains special
  610. character sequences starting with `%' to say how to encode the
  611. parameters.  These sequences control the actions of `tparam' and
  612. `tgoto'.
  613.  
  614. The parameters values passed to `tparam' or `tgoto' are considered to
  615. form a vector.  A pointer into this vector determines the next
  616. parameter to be processed.  Some of the `%'-sequences encode one
  617. parameter and advance the pointer to the next parameter.  Other
  618. `%'-sequences alter the pointer or alter the parameter values without
  619. generating output.
  620.  
  621. For example, the `cm' string for a standard ANSI terminal is written
  622. as `\E[%i%d;%dH'.  (`\E' stands for ESC.)  `cm' by convention always
  623. requires two parameters, the vertical and horizontal goal positions,
  624. so this string specifies the encoding of two parameters.  Here `%i'
  625. increments the two values supplied, and each `%d' encodes one of the
  626. values in decimal.  If the cursor position values 20,58 are encoded
  627. with this string, the result is `\E[21;59H'.
  628.  
  629. First, here are the `%'-sequences that generate output.  Except for
  630. `%%', each of them encodes one parameter and advances the pointer to
  631. the following parameter.
  632.  
  633. `%%'
  634.      Output a single `%'.  This is the only way to represent a
  635.      literal `%' in a terminal command with parameters.  `%%' does
  636.      not use up a parameter.
  637.  
  638. `%d'
  639.      As in `printf', output the next parameter in decimal.
  640.  
  641. `%2'
  642.      Like `%02d' in `printf': output the next parameter in decimal,
  643.      and always use at least two digits.
  644.  
  645. `%3'
  646.      Like `%03d' in `printf': output the next parameter in decimal,
  647.      and always use at least three digits.  Note that `%4' and so on
  648.      are *not* defined.
  649.  
  650. `%.'
  651.      Output the next parameter as a single character whose ASCII code
  652.      is the parameter value.  Like `%c' in `printf'.
  653.  
  654. `%+CHAR'
  655.      Add the next parameter to the character CHAR, and output the
  656.      resulting character.  For example, `%+ ' represents 0 as a
  657.      space, 1 as `!', etc.
  658.  
  659. The following `%'-sequences specify alteration of the parameters
  660. (their values, or their order) rather than encoding a parameter for
  661. output.  They generate no output; they are used only for their side
  662. effects on the parameters.  Also, they do not advance the "next
  663. parameter" pointer except as explicitly stated.  Only `%i', `%r' and
  664. `%>' are defined in standard Unix termcap.  The others are GNU
  665. extensions.
  666.  
  667. `%i'
  668.      Increment the next two parameters.  This is used for terminals
  669.      that expect cursor positions in origin 1.  For example,
  670.      `%i%d,%d' would output two parameters with `1' for 0, `2' for 1,
  671.      etc.
  672.  
  673. `%r'
  674.      Interchange the next two parameters.  This is used for terminals
  675.      whose cursor positioning command expects the horizontal position
  676.      first.
  677.  
  678. `%s'
  679.      Skip the next parameter.  Do not output anything.
  680.  
  681. `%b'
  682.      Back up one parameter.  The last parameter used will become once
  683.      again the next parameter to be output, and the next output
  684.      command will use it.  Using `%b' more than once, you can back up
  685.      any number of parameters, and you can refer to each parameter
  686.      any number of times.
  687.  
  688. `%>C1C2'
  689.      Conditionally increment the next parameter.  Here C1 and C2 are
  690.      characters which stand for their ASCII codes as numbers.  If the
  691.      next parameter is greater than the ASCII code of C1, the ASCII
  692.      code of C2 is added to it.
  693.  
  694. `%a OP TYPE POS'
  695.      Perform arithmetic on the next parameter, do not use it up, and
  696.      do not output anything.  Here OP specifies the arithmetic
  697.      operation, while TYPE and POS together specify the other operand.
  698.  
  699.      Spaces are used above to separate the operands for clarity; the
  700.      spaces don't appear in the data base, where this sequence is
  701.      exactly five characters long.
  702.  
  703.      The character OP says what kind of arithmetic operation to
  704.      perform.  It can be any of these characters:
  705.  
  706.     `='
  707.           assign a value to the next parameter, ignoring its old value.
  708.           The new value comes from the other operand.
  709.  
  710.     `+'
  711.           add the other operand to the next parameter.
  712.  
  713.     `-'
  714.           subtract the other operand from the next parameter.
  715.  
  716.     `*'
  717.           multiply the next parameter by the other operand.
  718.  
  719.     `/'
  720.           divide the next parameter by the other operand.
  721.  
  722.      The "other operand" may be another parameter's value or a
  723.      constant; the character TYPE says which.  It can be:
  724.  
  725.     `p'
  726.           Use another parameter.  The character POS says which
  727.           parameter to use.  Subtract 64 from its ASCII code to get
  728.           the position of the desired parameter relative to this one.
  729.           Thus, the character `A' as POS means the parameter after
  730.           the next one; the character `?' means the parameter before
  731.           the next one.
  732.  
  733.     `c'
  734.           Use a constant value.  The character POS specifies the
  735.           value of the constant.  The 0200 bit is cleared out, so
  736.           that 0200 can be used to represent zero.
  737.  
  738. The following `%'-sequences are special purpose hacks to compensate
  739. for the weird designs of obscure terminals.  They modify the next
  740. parameter or the next two parameters but do not generate output and
  741. do not use up any parameters.  `%m' is a GNU extension; the others
  742. are defined in standard Unix termcap.
  743.  
  744. `%n'
  745.      Exclusive-or the next parameter with 0140, and likewise the
  746.      parameter after next.
  747.  
  748. `%m'
  749.      Complement all the bits of the next parameter and the parameter
  750.      after next.
  751.  
  752. `%B'
  753.      Encode the next parameter in BCD.  It alters the value of the
  754.      parameter by adding six times the quotient of the parameter by
  755.      ten.  Here is a C statement that shows how the new value is
  756.      computed:
  757.  
  758.           PARM = (PARM / 10) * 16 + PARM % 10;
  759.  
  760. `%D'
  761.      Transform the next parameter as needed by Delta Data terminals. 
  762.      This involves subtracting twice the remainder of the parameter
  763.      by 16.
  764.  
  765.           PARM -= 2 * (PARM % 16);
  766.  
  767.  
  768. 
  769. File: termcap,  Node: Using Parameters,  Prev: Encode Parameters,  Up: Parameters
  770.  
  771. Sending Display Commands with Parameters
  772. ----------------------------------------
  773.  
  774. The termcap library functions `tparam' and `tgoto' serve as the
  775. analog of `printf' for terminal string parameters.  The newer
  776. function `tparam' is a GNU extension, more general but missing from
  777. Unix termcap.  The original parameter-encoding function is `tgoto',
  778. which is preferable for cursor motion.
  779.  
  780. * Menu:
  781.  
  782. * tparam::   The general case, for GNU termcap only.
  783. * tgoto::    The special case of cursor motion.
  784.  
  785.  
  786. 
  787. File: termcap,  Node: tparam,  Next: tgoto,  Prev: Using Parameters,  Up: Using Parameters
  788.  
  789. `tparam'
  790. ........
  791.  
  792.  The function `tparam' can encode display commands with any number of
  793. parameters and allows you to specify the buffer space.  It is the
  794. preferred function for encoding parameters for all but the `cm'
  795. capability.  Its ANSI C declaration is as follows:
  796.  
  797.      char *tparam (char *CTLSTRING, char *BUFFER, int SIZE, int PARM1,...)
  798.  
  799. The arguments are a control string CTLSTRING (the value of a terminal
  800. capability, presumably), an output buffer BUFFER and SIZE, and any
  801. number of integer parameters to be encoded.  The effect of `tparam'
  802. is to copy the control string into the buffer, encoding parameters
  803. according to the `%' sequences in the control string.
  804.  
  805. You describe the output buffer by its address, BUFFER, and its size
  806. in bytes, SIZE.  If the buffer is not big enough for the data to be
  807. stored in it, `tparam' calls `malloc' to get a larger buffer.  In
  808. either case, `tparam' returns the address of the buffer it ultimately
  809. uses.  If the value equals BUFFER, your original buffer was used. 
  810. Otherwise, a new buffer was allocated, and you must free it after you
  811. are done with printing the results.  If you pass zero for SIZE and
  812. BUFFER, `tparam' always allocates the space with `malloc'.
  813.  
  814. All capabilities that require parameters also have the ability to
  815. specify padding, so you should use `tputs' to output the string
  816. produced by `tparam'.  *Note Padding::.  Here is an example.
  817.  
  818.      {
  819.        char *buf;
  820.        char buffer[40];
  821.      
  822.        buf = tparam (command, buffer, 40, parm);
  823.        tputs (buf, 1, fputchar);
  824.        if (buf != buffer)
  825.          free (buf);
  826.      }
  827.  
  828. If a parameter whose value is zero is encoded with `%.'-style
  829. encoding, the result is a null character, which will confuse `tputs'.
  830. This would be a serious problem, but luckily `%.' encoding is used
  831. only by a few old models of terminal, and only for the `cm'
  832. capability.  To solve the problem, use `tgoto' rather than `tparam'
  833. to encode the `cm' capability.
  834.  
  835.  
  836. 
  837. File: termcap,  Node: tgoto,  Prev: tparam,  Up: Using Parameters
  838.  
  839. `tgoto'
  840. .......
  841.  
  842.  The special case of cursor motion is handled by `tgoto'.  There are
  843. two reasons why you might choose to use `tgoto':
  844.  
  845.    * For Unix compatibility, because Unix termcap does not have
  846.      `tparam'.
  847.  
  848.    * For the `cm' capability, since `tgoto' has a special feature to
  849.      avoid problems with null characters, tabs and newlines on
  850.      certain old terminal types that use `%.' encoding for that
  851.      capability.
  852.  
  853. Here is how `tgoto' might be declared in ANSI C:
  854.  
  855.      char *tgoto (char *CSTRING, int HPOS, int VPOS)
  856.  
  857. There are three arguments, the terminal description's `cm' string and
  858. the two cursor position numbers; `tgoto' computes the parametrized
  859. string in an internal static buffer and returns the address of that
  860. buffer.  The next time you use `tgoto' the same buffer will be reused.
  861.  
  862. Parameters encoded with `%.' encoding can generate null characters,
  863. tabs or newlines.  These might cause trouble: the null character
  864. because `tputs' would think that was the end of the string, the tab
  865. because the kernel or other software might expand it into spaces, and
  866. the newline becaue the kernel might add a carriage-return, or padding
  867. characters normally used for a newline.  To prevent such problems,
  868. `tgoto' is careful to avoid these characters.  Here is how this
  869. works: if the target cursor position value is such as to cause a
  870. problem (that is to say, zero, nine or ten), `tgoto' increments it by
  871. one, then compensates by appending a string to move the cursor back
  872. or up one position.
  873.  
  874. The compensation strings to use for moving back or up are found in
  875. global variables named `BC' and `UP'.  These are actual external C
  876. variables with upper case names; they are declared `char *'.  It is
  877. up to you to store suitable values in them, normally obtained from
  878. the `le' and `up' terminal capabilities in the terminal description
  879. with `tgetstr'.  Alternatively, if these two variables are both zero,
  880. the feature of avoiding nulls, tabs and newlines is turned off.
  881.  
  882. It is safe to use `tgoto' for commands other than `cm' only if you
  883. have stored zero in `BC' and `UP'.
  884.  
  885. Note that `tgoto' reverses the order of its operands: the horizontal
  886. position comes before the vertical position in the arguments to
  887. `tgoto', even though the vertical position comes before the
  888. horizontal in the parameters of the `cm' string.  If you use `tgoto'
  889. with a command such as `AL' that takes one parameter, you must pass
  890. the parameter to `tgoto' as the "vertical position".
  891.  
  892.  
  893. 
  894. File: termcap,  Node: Data Base,  Next: Capabilities,  Prev: Library,  Up: Top
  895.  
  896. The Format of the Data Base
  897. ***************************
  898.  
  899. The termcap data base of terminal descriptions is stored in the file
  900. `/etc/termcap'.  It contains terminal descriptions, blank lines, and
  901. comments.
  902.  
  903. A terminal description starts with one or more names for the terminal
  904. type.  The information in the description is a series of "capability
  905. names" and values.  The capability names have standard meanings
  906. (*note Capabilities::.) and their values describe the terminal.
  907.  
  908. * Menu:
  909.  
  910. * Format::            Overall format of a terminal description.
  911. * Capability Format:: Format of capabilities within a description.
  912. * Naming::            Naming conventions for terminal types.
  913. * Inheriting::        Inheriting part of a description from
  914.                         a related terminal type.
  915.  
  916.  
  917. 
  918. File: termcap,  Node: Format,  Next: Capability Format,  Prev: Data Base,  Up: Data Base
  919.  
  920. Terminal Description Format
  921. ===========================
  922.  
  923. Aside from comments (lines starting with `#', which are ignored),
  924. each nonblank line in the termcap data base is a terminal description.
  925. A terminal description is nominally a single line, but it can be
  926. split into multiple lines by inserting the two characters `\ newline'.
  927. This sequence is ignored wherever it appears in a description.
  928.  
  929. The preferred way to split the description is between capabilities:
  930. insert the four characters `: \ newline tab' immediately before any
  931. colon.  This allows each sub-line to start with some indentation. 
  932. This works because, after the `\ newline' are ignored, the result is
  933. `: tab :'; the first colon ends the preceding capability and the
  934. second colon starts the next capability.  If you split with `\
  935. newline' alone, you may not add any indentation after them.
  936.  
  937. Here is a real example of a terminal description:
  938.  
  939.      dw|vt52|DEC vt52:\
  940.              :cr=^M:do=^J:nl=^J:bl=^G:\
  941.              :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:li#24:\
  942.              :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\
  943.              :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H:
  944.  
  945. Each terminal description begins with several names for the terminal
  946. type.  The names are separated by `|' characters, and a colon ends
  947. the last name.  The first name should be two characters long; it
  948. exists only for the sake of very old Unix systems and is never used
  949. in modern systems.  The last name should be a fully verbose name such
  950. as "DEC vt52" or "Ann Arbor Ambassador with 48 lines".  The other
  951. names should include whatever the user ought to be able to specify to
  952. get this terminal type, such as `vt52' or `aaa-48'.  *Note Naming::,
  953. for information on how to choose terminal type names.
  954.  
  955. After the terminal type names come the terminal capabilities,
  956. separated by colons and with a colon after the last one.  Each
  957. capability has a two-letter name, such as `cm' for "cursor motion
  958. string" or `li' for "number of display lines".
  959.  
  960.  
  961. 
  962. File: termcap,  Node: Capability Format,  Next: Naming,  Prev: Format,  Up: Data Base
  963.  
  964. Writing the Capabilities
  965. ========================
  966.  
  967. There are three kinds of capabilities: flags, numbers, and strings. 
  968. Each kind has its own way of being written in the description.  Each
  969. defined capability has by convention a particular kind of value; for
  970. example, `li' always has a numeric value and `cm' always a string
  971. value.
  972.  
  973. A flag capability is thought of as having a boolean value: the value
  974. is true if the capability is present, false if not.  When the
  975. capability is present, just write its name between two colons.
  976.  
  977. A numeric capability has a value which is a nonnegative number. 
  978. Write the capability name, a `#', and the number, between two colons.
  979. For example, `...:li#48:...' is how you specify the `li' capability
  980. for 48 lines.
  981.  
  982. A string-valued capability has a value which is a sequence of
  983. characters.  Usually these are the characters used to perform some
  984. display operation.  Write the capability name, a `=', and the
  985. characters of the value, between two colons.  For example,
  986. `...:cm=\E[%i%d;%dH:...' is how the cursor motion command for a
  987. standard ANSI terminal would be specified.
  988.  
  989. Special characters in the string value can be expressed using
  990. `\'-escape sequences as in C; in addition, `\E' stands for ESC.  `^'
  991. is also a kind of escape character; `^' followed by CHAR stands for
  992. the control-equivalent of CHAR.  Thus, `^a' stands for the character
  993. control-a, just like `\001'.  `\' and `^' themselves can be
  994. represented as `\\' and `\^'.
  995.  
  996. To include a colon in the string, you must write `\072'.  You might
  997. ask, "Why can't `\:' be used to represent a colon?"  The reason is
  998. that the interrogation functions do not count slashes while looking
  999. for a capability.  Even if `:ce=ab\:cd:' were interpreted as giving
  1000. the `ce' capability the value `ab:cd', it would also appear to define
  1001. `cd' as a flag.
  1002.  
  1003. The string value will often contain digits at the front to specify
  1004. padding (*note Padding::.) and/or `%'-sequences within to specify how
  1005. to encode parameters (*note Parameters::.).  Although these things
  1006. are not to be output literally to the terminal, they are considered
  1007. part of the value of the capability.  They are special only when the
  1008. string value is processed by `tputs', `tparam' or `tgoto'.  By
  1009. contrast, `\' and `^' are considered part of the syntax for
  1010. specifying the characters in the string.
  1011.  
  1012. Let's look at the VT52 example again:
  1013.  
  1014.      dw|vt52|DEC vt52:\
  1015.              :cr=^M:do=^J:nl=^J:bl=^G:\
  1016.              :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:li#24:\
  1017.              :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\
  1018.              :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H:
  1019.  
  1020. Here we see the numeric-valued capabilities `co' and `li', the flags
  1021. `bs' and `pt', and many string-valued capabilities.  Most of the
  1022. strings start with ESC represented as `\E'.  The rest contain control
  1023. characters represented using `^'.  The meanings of the individual
  1024. capabilities are defined elsewhere (*note Capabilities::.).
  1025.  
  1026.  
  1027. 
  1028. File: termcap,  Node: Naming,  Next: Inheriting,  Prev: Capability Format,  Up: Data Base
  1029.  
  1030. Terminal Type Name Conventions
  1031. ==============================
  1032.  
  1033. There are conventions for choosing names of terminal types.  For one
  1034. thing, all letters should be in lower case.  The terminal type for a
  1035. terminal in its most usual or most fundamental mode of operation
  1036. should not have a hyphen in it.
  1037.  
  1038. If the same terminal has other modes of operation which require
  1039. different terminal descriptions, these variant descriptions are given
  1040. names made by adding suffixes with hyphens.  Such alternate
  1041. descriptions are used for two reasons:
  1042.  
  1043.    * When the terminal has a switch that changes its behavior.  Since
  1044.      the computer cannot tell how the switch is set, the user must
  1045.      tell the computer by choosing the appropriate terminal type name.
  1046.  
  1047.      For example, the VT-100 has a setup flag that controls whether
  1048.      the cursor wraps at the right margin.  If this flag is set to
  1049.      "wrap", you must use the terminal type `vt100-am'.  Otherwise
  1050.      you must use `vt100-nam'.  Plain `vt100' is defined as a synonym
  1051.      for either `vt100-am' or `vt100-nam' depending on the
  1052.      preferences of the local site.
  1053.  
  1054.      The standard suffix `-am' stands for "automatic margins".
  1055.  
  1056.    * To give the user a choice in how to use the terminal.  This is
  1057.      done when the terminal has a switch that the computer normally
  1058.      controls.
  1059.  
  1060.      For example, the Ann Arbor Ambassador can be configured with
  1061.      many screen sizes ranging from 20 to 60 lines.  Fewer lines make
  1062.      bigger characters but more lines let you see more of what you
  1063.      are editing.  As a result, users have different preferences. 
  1064.      Therefore, termcap provides terminal types for many screen
  1065.      sizes.  If you choose type `aaa-30', the terminal will be
  1066.      configured to use 30 lines; if you choose `aaa-48', 48 lines
  1067.      will be used, and so on.
  1068.  
  1069. Here is a list of standard suffixes and their conventional meanings:
  1070.  
  1071. `-w'
  1072.      Short for "wide".  This is a mode that gives the terminal more
  1073.      columns than usual.  This is normally a user option.
  1074.  
  1075. `-am'
  1076.      "Automatic margins".  This is an alternate description for use
  1077.      when the terminal's margin-wrap switch is on; it contains the
  1078.      `am' flag.  The implication is that normally the switch is off
  1079.      and the usual description for the terminal says that the switch
  1080.      is off.
  1081.  
  1082. `-nam'
  1083.      "No automatic margins".  The opposite of `-am', this names an
  1084.      alternative description which lacks the `am' flag.  This implies
  1085.      that the terminal is normally operated with the margin-wrap
  1086.      switch turned on, and the normal description of the terminal
  1087.      says so.
  1088.  
  1089. `-na'
  1090.      "No arrows".  This terminal description initializes the terminal
  1091.      to keep its arrow keys in local mode.  This is a user option.
  1092.  
  1093. `-rv'
  1094.      "Reverse video".  This terminal description causes text output
  1095.      for normal video to appear as reverse, and text output for
  1096.      reverse video to come out as normal.  Often this description
  1097.      differs from the usual one by interchanging the two strings
  1098.      which turn reverse video on and off.
  1099.  
  1100.      This is a user option; you can choose either the "reverse video"
  1101.      variant terminal type or the normal terminal type, and termcap
  1102.      will obey.
  1103.  
  1104. `-s'
  1105.      "Status".  Says to enable use of a status line which ordinary
  1106.      output does not touch (*note Status Line::.).
  1107.  
  1108.      Some terminals have a special line that is used only as a status
  1109.      line.  For these terminals, there is no need for an `-s'
  1110.      variant; the status line commands should be defined by default. 
  1111.      On other terminals, enabling a status line means removing one
  1112.      screen line from ordinary use and reducing the effective screen
  1113.      height.  For these terminals, the user can choose the `-s'
  1114.      variant type to request use of a status line.
  1115.  
  1116. `-NLINES'
  1117.      Says to operate with NLINES lines on the screen, for terminals
  1118.      such as the Ambassador which provide this as an option. 
  1119.      Normally this is a user option; by choosing the terminal type,
  1120.      you control how many lines termcap will use.
  1121.  
  1122. `-NPAGESp'
  1123.      Says that the terminal has NPAGES pages worth of screen memory,
  1124.      for terminals where this is a hardware option.
  1125.  
  1126. `-unk'
  1127.      Says that description is not for direct use, but only for
  1128.      reference in `tc' capabilities.  Such a description is a kind of
  1129.      subroutine, because it describes the common characteristics of
  1130.      several variant descriptions that would use other suffixes in
  1131.      place of `-unk'.
  1132.  
  1133.  
  1134. 
  1135. File: termcap,  Node: Inheriting,  Prev: Naming,  Up: Data Base
  1136.  
  1137. Inheriting from Related Descriptions
  1138. ====================================
  1139.  
  1140. When two terminal descriptions are similar, their identical parts do
  1141. not need to be given twice.  Instead, one of the two can be defined
  1142. in terms of the other, using the `tc' capability.  We say that one
  1143. description "refers to" the other, or "inherits from" the other.
  1144.  
  1145. The `tc' capability must be the last one in the terminal description,
  1146. and its value is a string which is the name of another terminal type
  1147. which is referred to.  For example,
  1148.  
  1149.      N9|aaa|ambassador|aaa-30|ann arbor ambassador/30 lines:\
  1150.              :ti=\E[2J\E[30;0;0;30p:\
  1151.              :te=\E[60;0;0;30p\E[30;1H\E[J:\
  1152.              :li#30:tc=aaa-unk:
  1153.  
  1154. defines the terminal type `aaa-30' (also known as plain `aaa') in
  1155. terms of `aaa-unk', which defines everything about the Ambassador
  1156. that is independent of screen height.  The types `aaa-36', `aaa-48'
  1157. and so on for other screen heights are likewise defined to inherit
  1158. from `aaa-unk'.
  1159.  
  1160. The capabilities overridden by `aaa-30' include `li', which says how
  1161. many lines there are, and `ti' and `te', which configure the terminal
  1162. to use that many lines.
  1163.  
  1164. The effective terminal description for type `aaa' consists of the
  1165. text shown above followed by the text of the description of
  1166. `aaa-unk'.  The `tc' capability is handled automatically by
  1167. `tgetent', which finds the description thus referenced and combines
  1168. the two descriptions (*note Find::.).  Therefore, only the
  1169. implementor of the terminal descriptions needs to think about using
  1170. `tc'.  Users and application programmers do not need to be concerned
  1171. with it.
  1172.  
  1173. Since the reference terminal description is used last, capabilities
  1174. specified in the referring description override any specifications of
  1175. the same capabilities in the reference description.
  1176.  
  1177. The referring description can cancel out a capability without
  1178. specifying any new value for it by means of a special trick.  Write
  1179. the capability in the referring description, with the character `@'
  1180. after the capability name, as follows:
  1181.  
  1182.      NZ|aaa-30-nam|ann arbor ambassador/30 lines/no automatic-margins:\
  1183.              :am@:tc=aaa-30:
  1184.  
  1185.  
  1186.